class Parenthesis {
public:
    bool chkParenthesis(string A, int n) {
        // write code here
        stack<char> sc;
        for(auto ch : A)
        {
            switch(ch)
            {
                case '(':
                    sc.push(ch);
                    break;
                case ')':
                    if(sc.empty())
                        return false;//多出右半边
                    sc.pop();
                    break;
                default:
                    return false;//遇到非括号字符
            }
        }
        return sc.empty();//多出左半边
    }
};
